import Vue from 'vue'
import VueRouter from 'vue-router'
//导入一级路由
import Login from "../views/login"
import Layout from "../views/layout"

Vue.use(VueRouter)

const routes = [
    { path: "/", redirect: "/login" },
    { path: "/login", component: Login },
    {
        path: "/home",
        component: Layout,
        redirect: "/home",
        children: [{
            path: "",
            component: () =>
                import ("../views/home/index.vue")
        }]
    },
    {
        path: "/users",
        component: Layout,
        redirect: "/users/users",
        children: [{
            path: "users",
            component: () =>
                import ("../views/users/index.vue")
        }]
    },
    {
        path: "/rights",
        component: Layout,
        redirect: "/rights/roles",
        children: [{
                path: "roles",
                component: () =>
                    import ("../views/auth/role.vue")
            },
            {
                path: "rights",
                component: () =>
                    import ("../views/auth/right.vue")
            }
        ]
    },
    {
        path: "/goods",
        meta: { title: "商品管理" },
        component: Layout,
        redirect: "/goods",
        children: [{
                path: "goods",
                meta: { title: "商品列表" },
                component: () =>
                    import ("../views/goods/goods.vue")
            },
            {
                path: "params",
                meta: { title: "分类参数" },
                component: () =>
                    import ("../views/goods/params.vue")
            },
            {
                path: "categories",
                meta: { title: "商品分类" },
                component: () =>
                    import ("../views/goods/categories.vue")
            },
            {
                path: "goodsJump",
                meta: { title: "商品添加" },
                component: () =>
                    import ("../views/goods/goodsJump.vue")
            }
        ]
    },
    //订单管理
    {
        path: "/orders",
        meta: { title: "订单管理" },
        component: Layout,
        redirect: "/orders",
        children: [
            { path: "orders", meta: { title: "订单列表" }, component: () =>
                    import ("../views/orders/index.vue") }
        ]
    },
    //数据统计
    {
        path: "/reports",
        meta: { title: "数据统计" },
        component: Layout,
        redirect: "/reports",
        children: [
            { path: "reports", meta: { title: "数据报表" }, component: () =>
                    import ("../views/reports/index.vue") }
        ]
    },

]

const router = new VueRouter({
    routes
})

export default router